﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Popup_Mat_Add.aspx.cs" Inherits="Popup_Popup_Mat_Add" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>제목 없음</title>
    <link href="../CustomCss.css" rel="stylesheet" type="text/css" />
    <link href="../resources/css/examples.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .my-grid .x-grid3-scroller
        {
            overflow: scroll;
        }
        
        .item
        {
            font-size: 9pt;
        }
    </style>
    <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
            var removeJaje = function () {
                var grid = #{GridPanel1};
                grid.stopEditing();
                
                var s = grid.getSelectionModel().getSelections();
                
                for (var i = 0, r; r = s[i]; i++) {
                    #{Store1}.remove(r);
                }
                
            }
            
            var addMat = function () {
                var grid = #{GridPanel1};
                grid.stopEditing();
                var index =  #{Store1}.getCount();
                
                grid.insertRecord(index, {
                });
                
                grid.getView().focusRow(index);
                grid.getView().focusCell(index,2);
                grid.selModel.selectRow(index);
                grid.startEditing(index,2);
            }
        </script>
    </ext:XScript>
        

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Store ID="StrClass1" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="MK_CLASS">
                <Fields>
                    <ext:RecordField Name="MK_CLASS" />
                    <ext:RecordField Name="NAME" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StrClass2" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="CLASS">
                <Fields>
                    <ext:RecordField Name="CLASS" />
                    <ext:RecordField Name="NAME" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <span>업체별 발주단가</span>
    <ext:Panel ID="Panel1" runat="server" Title="">
        <Content>
            <table>
                <tr>
                    <td class="item" style="width: 50px;">자재명</td>
                    <td>
                        <ext:TextField ID="tbxName" runat="server" ReadOnly="true" Width="100"></ext:TextField>
                    </td>
                    <td class="item" style="width: 50px;">규격</td>
                    <td>
                        <ext:TextField ID="tbxSpec" runat="server"  ReadOnly="true" Width="100"></ext:TextField>
                    </td>
                    <td class="item" style="width: 50px;">단위</td>
                    <td>
                        <ext:TextField ID="tbxUnit" runat="server"  ReadOnly="true" Width="100"></ext:TextField>
                    </td>
                    <td class="item" style="width: 50px;">단가</td>
                    <td>
                        <ext:NumberField ID="tbxUc" runat="server" Width="100"></ext:NumberField>
                    </td>
                </tr>
                <tr>
                    <td class="item">자재코드</td>
                    <td>
                        <ext:TextField ID="tbxCode" runat="server" ReadOnly="true" Width="100"></ext:TextField>
                    </td>
                    <td class="item">비고</td>
                    <td colspan="4">
                        <ext:TextField ID="tbxRemark" runat="server" StyleSpec="width:70%;"></ext:TextField>
                    </td>
                    <td>
                        <ext:Button ID="btnSave300" runat="server" Icon="Disk" Text="저장">
                            <DirectEvents>
                                <Click OnEvent="btnSave_Click">
                                    <EventMask ShowMask="true" Msg="저장중입니다..." MinDelay="50" />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </td>
                </tr>
            </table>
        </Content>
    </ext:Panel>
    <br />
    <span>표준 DB 자재</span>
    <ext:GridPanel ID="GridPanel1" runat="server" AutoScroll="true" Height="150" HideBorders="true"  HideHeaders="false" >
        <Store>
            <ext:Store ID="Store1" runat="server" WarningOnDirty="false" OnRefreshData="Store_RefreshData" OnBeforeStoreChanged="Store_BeforeChanged">
                <Reader>
                    <ext:JsonReader>
                        <Fields>
                            <ext:RecordField Name="MA_CD" />
                            <ext:RecordField Name="NAME" />
                            <ext:RecordField Name="SPEC" />
                            <ext:RecordField Name="UNIT" />
                            <ext:RecordField Name="UC" />
                            <ext:RecordField Name="REMARK" />
                            <ext:RecordField Name="REG_DT" />
                            <ext:RecordField Name="REG_NAME" />
                            <ext:RecordField Name="CLASS" />
                            <ext:RecordField Name="DESCRIPTION" />
                            <ext:RecordField Name="MA_DT" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
                <Listeners>
                    <LoadException Handler="var e = e || {메시지: response.responseText}; alert('로드하지 못했습니다.: ' + e.message);" />
                </Listeners>
            </ext:Store>
        </Store>
        <View>
            <ext:GridView ID="GridView1" runat="server" />
        </View>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:RowNumbererColumn />
                <ext:Column ColumnID="MA_CD" Header="코드" Width="80" DataIndex="MA_CD" Editable="true">
                    <Editor>
                        <ext:TextField ID="tbxMA_CD" runat="server"></ext:TextField>
                    </Editor>
                </ext:Column>
                <ext:Column ColumnID="NAME" Header="이름" Width="100" DataIndex="NAME" Locked="false" />
                <ext:Column ColumnID="SPEC" Header="규격" Width="80" DataIndex="SPEC" Editable="true" />
                <ext:Column ColumnID="UNIT" Header="단위" Width="50" DataIndex="UNIT" Editable="true" />
                <ext:Column ColumnID="UC" Header="단가" Width="80" DataIndex="UC" Align="Right" Editable="true">
                    <Renderer Format="Number" FormatArgs="'0,0'" />
                </ext:Column>
                <ext:Column ColumnID="REMARK" Header="비고" Width="120" DataIndex="REMARK" Editable="true" />
            </Columns>
        </ColumnModel>
        <TopBar>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:Label ID="lbl1" Text="대분류" runat="server"></ext:Label>
                    <ext:ComboBox ID="cbxUpClass" runat="server" Width="100" StoreID="StrClass1" DisplayField="NAME" ValueField="MK_CLASS">
                        <DirectEvents>
                            <Select OnEvent="ChangeGubun"></Select>
                        </DirectEvents>
                    </ext:ComboBox>
                    <ext:Label ID="lbl2" Text="소분류" runat="server"></ext:Label>
                    <ext:ComboBox ID="cbxClass" runat="server" Width="100" StoreID="StrClass2" DisplayField="NAME" ValueField="CLASS">

                    </ext:ComboBox>
                    <ext:Label ID="lbl3" Text="자재명" runat="server"></ext:Label><ext:TextField ID="tbxMatName" Width="80" runat="server"></ext:TextField>
                    <ext:ToolbarFill ID="ToolbarFill2" runat="server" />
                    <ext:Button ID="btnInquiry" runat="server" Text="조회" Icon="Zoom">
                        <Listeners>
                            <Click Handler="#{GridPanel1}.reload();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnMatInsert" runat="server" Text="추가" Icon="Add">
                        <DirectEvents>
                            <Click OnEvent="btnInser_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btnMatUpdate" runat="server" Text="수정" Icon="Add">
                        <DirectEvents>
                            <Click OnEvent="btnInser_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btnSave" runat="server" Text="저장" Icon="Disk">
                        <Listeners>
                            <Click Handler="#{GridPanel1}.save();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnDelete" runat="server" Text="삭제" Icon="Delete">
                        <Listeners>
                            <Click Fn="removeJaje" />
                        </Listeners>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                <DirectEvents>
                    <RowSelect OnEvent="MovePara">
                        <ExtraParams>
                            <ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))"
                                Mode="Raw" />
                        </ExtraParams>
                    </RowSelect>
                </DirectEvents>
            </ext:RowSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
    <ext:Hidden ID="hdRegNo" runat="server"></ext:Hidden>
    </form>
</body>
</html>
